package com.gujiangbo.chapter15;

/**
 * @Author: gujiangbo.co
 * @Contact: 646832012@qq.com
 * @Date: 2022/4/8 22:08
 * @Version: 1.0
 * @Description:
 * -XX:+PrintGCDetails
 */
public class JavaFinalize {

    public static void main(String[] args) {
        Person person = new Person("张三", "34");
        System.out.println(person);
        person = null;
        System.gc();

    }
}
class Person {
    private String name;
    private String age;

    public Person() {
        System.out.println("init");
    }

    public Person(String name, String age) {
        this.name = name;
        this.age = age;
    }

    @Override
    protected void finalize() throws Throwable {
        System.out.println("destroy..");
    }
}